<!--订单-->
<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link href="../css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="../css/order.css" />
</head>
<body class="gray">
	<div id="refreshContainer" class="mui-content mui-scroll-wrapper" style="padding-bottom: 60px;">
		<div class="mui-scroll loading" id="vueMain">
			<div v-if="list.length==0">
				<p style="padding:50px 0;text-align: center;">一个订单也没有哦!</p>
			</div>
			<div v-else>
				<template v-for="(item, index) in list">
					<ul class="mui-table-view">
				        <li class="mui-table-view-cell tls">
				        		<span class="status">{{item.order_status_name}}</span>
				        		<div class="mui-input-row mui-checkbox listCheckbox mui-left" >
								<label style="padding-left: 25px;">NO.{{item.order_no}}</label>
								<input name="v1" :value="index" type="checkbox" :data-idx="index"  />
							</div>
				        </li>
				        <li class="mui-table-view-cell mui-media">
				        		<a href="javascript:;">
			    		            <img class="mui-media-object mui-pull-left link" :src="item.img" _id="productDetail" _href="productDetail.html" _title="产品详情" :_extras="'gid='+item.goods_id" />
			    		            <div class="mui-media-body link" _id="order_detail" _href="order_detail.html" _title="订单明细" :_extras="'order='+item.order_no">
			    		                <div class="name">{{item.name}}</div>
			    		                <p>{{item.start_time}}-{{item.end_time}}  共{{item.goods_nums}}天</p>
			    		                <p><span class="mui-pull-right">数量:{{item.amount}}</span><span v-if="item.stro">已选：{{item.stro}}</span></p>
			    		                <p>下单日期：{{item.create_time}}</p>
			    		            </div>
			    		             <p class="total" >可结算: <span>¥ {{item.order_amount}}</span></p>
			    		        </a>
				        </li>
			    		</ul>
				</template>
			</div>
	    	</div>
	</div>
	<div class="fixedBar" style="display: none;">
		<div class="mui-pull-right tijiao" >
			申请结算
		</div>
		<div class="cosn">
			<div class="mui-input-row mui-checkbox allCheckbox mui-left mui-pull-left">
				<label>全选</label>
				<input name="v1" value="1" type="checkbox" >
			</div>
			金额: <span id="money">¥ 0</span>
		</div>
	</div>
<script src="../js/mui.js"></script>
<script src="../js/vue.min.js"></script>
<script src="../js/bexta.js"></script>
<script src="../js/order.js"></script>
<script type="text/javascript">
	
	mui.plusReady(function () {
		
		
	    mui('body').on('tap', '.listCheckbox', function(){
	    		mui.later(function(){
	    			countOrder();
	    		},50)
	    });
	    mui('.fixedBar').on('tap', '.allCheckbox', function(){
	    		
	    		mui.later(function(){
	    			var ck = this.querySelector('input').checked ;
	    			mui.each(document.querySelectorAll('.listCheckbox input'), function(){
	    				this.checked = ck;
	    			});
	    			countOrder();
	    		},50, this)
	    });
	    mui('.fixedBar').on('tap', '.tijiao', function(){
	    		var order = countOrder();
	    		if( order.length < 1 ){
	    			mui.toast("请勾选订单");
	    			return ;
	    		}
	    		mui.confirm("确定要提交结算?", TITLE, CONFIRM, function(item){
	    			if( item.index == 1 ){
	    				bexta.ajax(api.apply_check_order, function(res,msg){
			    			mui.toast(msg);
			    			if( !res ){
			    				plus.webview.currentWebview().reload();
			    			}
			    		}, {data:{uid:bexta.getStorage(MERCHANT).uid, order_no:order.join(',')}});
	    			}
	    		});
	    });
	    
	    function countOrder(){
	    		var num = 0, order = [], moneys = 0;
	    		mui.each(document.querySelectorAll('.listCheckbox input'), function(){ 
    				if( this.checked ){
    					++num;
    					moneys += parseFloat(apps.list[this.getAttribute('data-idx')].order_amount);
    					order.push(apps.list[this.getAttribute('data-idx')].order_no);
    				}
    			});
    			document.querySelector('#money').innerHTML = '¥ ' + moneys;
    			return order;
	    }
	    
	    
	});
	
</script>
</body>
</html>